package io.gitee.dqcer.mcdull.uac.provider.web.car.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.gitee.dqcer.mcdull.uac.provider.web.car.domain.CarVehicleRepairVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.gitee.dqcer.mcdull.uac.provider.common.annotation.Log;
import io.gitee.dqcer.mcdull.uac.provider.common.core.controller.BaseController;
import io.gitee.dqcer.mcdull.uac.provider.common.core.domain.AjaxResult;
import io.gitee.dqcer.mcdull.uac.provider.common.enums.BusinessType;
import io.gitee.dqcer.mcdull.uac.provider.web.car.domain.CarVehicleRepair;
import io.gitee.dqcer.mcdull.uac.provider.web.car.service.ICarVehicleRepairService;
import io.gitee.dqcer.mcdull.uac.provider.common.utils.poi.ExcelUtil;
import io.gitee.dqcer.mcdull.uac.provider.common.core.page.TableDataInfo;

/**
 * 维修监控Controller
 * 
 * @author ruoyi
 * @date 2023-12-10
 */
@RestController
@RequestMapping("/car/repair")
public class CarVehicleRepairController extends BaseController
{
    @Autowired
    private ICarVehicleRepairService carVehicleRepairService;

    /**
     * 查询维修监控列表
     */
    @PreAuthorize("@ss.hasPermi('car:repair:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarVehicleRepair carVehicleRepair)
    {
        startPage();
        List<CarVehicleRepairVO> list = carVehicleRepairService.selectCarVehicleRepairList(carVehicleRepair);
        return getDataTable(list);
    }

    /**
     * 导出维修监控列表
     */
    @PreAuthorize("@ss.hasPermi('car:repair:export')")
    @Log(title = "维修监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarVehicleRepair carVehicleRepair)
    {
        List<CarVehicleRepairVO> list = carVehicleRepairService.selectCarVehicleRepairList(carVehicleRepair);
        ExcelUtil<CarVehicleRepairVO> util = new ExcelUtil<CarVehicleRepairVO>(CarVehicleRepairVO.class);
        util.exportExcel(response, list, "维修监控数据");
    }

    /**
     * 获取维修监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:repair:query')")
    @GetMapping(value = "/{repairId}")
    public AjaxResult getInfo(@PathVariable("repairId") Long repairId)
    {
        return success(carVehicleRepairService.selectCarVehicleRepairByRepairId(repairId));
    }

    /**
     * 新增维修监控
     */
    @PreAuthorize("@ss.hasPermi('car:repair:add')")
    @Log(title = "维修监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarVehicleRepair carVehicleRepair)
    {
        return toAjax(carVehicleRepairService.insertCarVehicleRepair(carVehicleRepair));
    }

    /**
     * 修改维修监控
     */
    @PreAuthorize("@ss.hasPermi('car:repair:edit')")
    @Log(title = "维修监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarVehicleRepair carVehicleRepair)
    {
        return toAjax(carVehicleRepairService.updateCarVehicleRepair(carVehicleRepair));
    }

    /**
     * 删除维修监控
     */
    @PreAuthorize("@ss.hasPermi('car:repair:remove')")
    @Log(title = "维修监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairIds}")
    public AjaxResult remove(@PathVariable Long[] repairIds)
    {
        return toAjax(carVehicleRepairService.deleteCarVehicleRepairByRepairIds(repairIds));
    }
}
